* Set working directory
cd "Replication"
use "Replication_data/df_pool.dta", clear


*Multilevel ordered logistic models

label var treatment "武装袭击"
label var urban "城市受访者"
label var female "女性受访者"
label var poverty "受访者贫困状态"
label var ownership "受访者财产所有"
label var age "受访者年龄"
label var education_dummy "受访者教育水平"
label var radio_news "收听收音机新闻"
label var ethnic_major "受访者属于主导民族"
label var president_coethnic "受访者与总统相同民族"

***************************** Figure 6 (a) ***************************** 

* model 1
meologit wom_empower treatment urban female poverty ownership age education_dummy ///
radio_news ethnic_major president_coethnic if COUNTRY == 24 || REGION: 
estimates store nigeria

* model 2
meologit wom_empower treatment urban female poverty ownership age education_dummy ///
radio_news ethnic_major president_coethnic if COUNTRY == 11 || REGION: 
estimates store mali

* model 3
meologit wom_empower treatment urban female poverty ownership age education_dummy ///
radio_news ethnic_major president_coethnic || COUNTRY: || REGION:
estimates store all

esttab nigeria  mali all using "Tex/meologit.tex",se parentheses ///
	nonumbers mtitles("\shortstack{Model 1\\(Nigeria)}" "\shortstack{Model 2\\(Mali)}" "\shortstack{Model 3\\(Poolled)}")  ///
 label star(* 0.10 ** 0.05 *** 0.01) title(Multilevel ordered logistic models\label{meologit})  replace 


coefplot ///
 (nigeria, lpatt(solid) lcol(black) msym(o) msize(2) mcol(black ) ciopts(lpatt(solid) lcol(black))  mlabposition(1) mlabsize(4.2) mlabgap(*2)) ///
  (mali, lpatt(solid) lcol(black) msym(triangle) msize(2) mcol(red ) ciopts(lpatt(solid) lcol(red))  mlabposition(1) mlabsize(4.2) mlabgap(*2)) ///
   (all, lpatt(solid) lcol(black) msym(square) msize(2) mcol(blue ) ciopts(lpatt(solid) lcol(blue))  mlabposition(1) mlabsize(4.2) mlabgap(*2)), ///
   scheme(s1mono)  plotregion(lcolor(none))  ///
 horizontal xline(0,lwidth(thin) lpattern(dash)) ///
	grid(none) ///
	levels(95) ///
	legend(size(medium) order(2 "尼日利亚(N=2304)" 4 "马里 (N=1164)" 6 "全部 (N=3468)" ) rows(1) region(lcolor(none))) ///
	title("", size(medium)) ///
	ylabel(, notick labsize(medium)) 
graph export Tex/multilevel.png,replace	
***************************** ***************************** ***************************** 
** Figure 6(b)
***** use different bandwidth
  
 
foreach v in  11 24  switch  {
	foreach d in 1 2 3 4 5 6 {
		* Without controls
	meologit  wom_empower treatment  urban female poverty ownership age education_dummy ///
radio_news ethnic_major president_coethnic if abs(attack_days) <=`d' & COUNTRY == `v' || REGION: 
		estimates store cnty`v'_`d'd
		gen double beta_cnty`v'_`d'd = _b[treatment]
	}
}
 
 
 foreach d in 1 2 3 4 5 6 {
		* Without controls
	meologit  wom_empower treatment  urban female poverty ownership age education_dummy ///
radio_news ethnic_major president_coethnic if abs(attack_days) <=`d' || COUNTRY: || REGION: 
		estimates store all_`d'd
		gen double beta_all_`d'd = _b[treatment]
	}
 
 
 
*** Figure 3: Main Effects on Incumbent Support
coefplot ///
	(cnty11_1d, keep(treatment)  lpatt(solid) lcol(black) msym(o) msize(2) mcol(black ) ciopts(lpatt(solid) lcol(black))  mlabposition(1) mlabsize(4.2) mlabgap(*2) ) ///
	(cnty24_1d, keep(treatment)  lpatt(solid) lcol(red) msym(triangle) msize(2) mcol(red ) ciopts(lpatt(solid) lcol(red)) mlabposition(6)mlabsize(4.2) mlabgap(*2)  ) ///
	(all_1d, keep(treatment)  lpatt(solid) lcol(blue) msym(square) msize(2) mcol(blue ) ciopts(lpatt(solid) lcol(blue)) mlabposition(6)mlabsize(4.2) mlabgap(*2)  ) ///	
	(cnty11_1d, keep(treatment)  lpatt(solid) lcol(none) msym(o) msize(2) mcol(none ) ciopts(lpatt(solid) lcol(none))  mlabposition(1) mlabsize(4.2) mlabgap(*2) ) ///
	(cnty11_1d, keep(treatment)  lpatt(solid) lcol(none) msym(o) msize(2) mcol(none ) ciopts(lpatt(solid) lcol(none))  mlabposition(1) mlabsize(4.2) mlabgap(*2) ) ///
	(cnty11_2d, keep(treatment)  lpatt(solid) lcol(black) msym(o) msize(2) mcol(black )  ciopts(lpatt(solid) lcol(black))  mlabposition(12)mlabsize(4.2) mlabgap(*2)  ) ///
	(cnty24_2d, keep(treatment)  lpatt(solid) lcol(red) msym(triangle) msize(2) mcol(red )  ciopts(lpatt(solid) lcol(red))  mlabposition(12)mlabsize(4.2) mlabgap(*2)  ) ///
	(all_2d, keep(treatment)  lpatt(solid) lcol(blue) msym(square) msize(2) mcol(blue )  ciopts(lpatt(solid) lcol(blue))  mlabposition(12)mlabsize(4.2) mlabgap(*2)  ) ///	
	(cnty11_2d, keep(treatment)  lpatt(solid) lcol(none) msym(o) msize(2) mcol(none ) ciopts(lpatt(solid) lcol(none))  mlabposition(1) mlabsize(4.2) mlabgap(*2) ) ///
	(cnty11_2d, keep(treatment)  lpatt(solid) lcol(none) msym(o) msize(2) mcol(none ) ciopts(lpatt(solid) lcol(none))  mlabposition(1) mlabsize(4.2) mlabgap(*2) ) ///
	(cnty11_3d, keep(treatment)  lpatt(solid) lcol(black) msym(o) msize(2) mcol(black )  ciopts(lpatt(solid) lcol(black))  mlabposition(12)mlabsize(4.2) mlabgap(*2)  ) ///
	(cnty24_3d, keep(treatment)  lpatt(solid) lcol(red) msym(triangle) msize(2) mcol(red )  ciopts(lpatt(solid) lcol(red))  mlabposition(12)mlabsize(4.2) mlabgap(*2)  ) ///
	(all_3d, keep(treatment)  lpatt(solid) lcol(blue) msym(square) msize(2) mcol(blue )  ciopts(lpatt(solid) lcol(blue))  mlabposition(12)mlabsize(4.2) mlabgap(*2)  ) ///	
	(cnty11_3d, keep(treatment)  lpatt(solid) lcol(none) msym(o) msize(2) mcol(none ) ciopts(lpatt(solid) lcol(none))  mlabposition(1) mlabsize(4.2) mlabgap(*2) ) ///
	(cnty11_3d, keep(treatment)  lpatt(solid) lcol(none) msym(o) msize(2) mcol(none ) ciopts(lpatt(solid) lcol(none))  mlabposition(1) mlabsize(4.2) mlabgap(*2) ) ///
	(cnty11_4d, keep(treatment)  lpatt(solid) lcol(black) msym(o) msize(2) mcol(black)  ciopts(lpatt(solid) lcol(black))  mlabposition(12)mlabsize(4.2) mlabgap(*2)  ) ///
	(cnty24_4d, keep(treatment)  lpatt(solid) lcol(red) msym(triangle) msize(2) mcol(red )  ciopts(lpatt(solid) lcol(red))  mlabposition(12)mlabsize(4.2) mlabgap(*2)  ) ///
	(all_4d, keep(treatment)  lpatt(solid) lcol(blue) msym(square) msize(2) mcol(blue )  ciopts(lpatt(solid) lcol(blue))  mlabposition(12)mlabsize(4.2) mlabgap(*2)  ) ///
	(cnty11_4d, keep(treatment)  lpatt(solid) lcol(none) msym(o) msize(2) mcol(none ) ciopts(lpatt(solid) lcol(none))  mlabposition(1) mlabsize(4.2) mlabgap(*2) ) ///
	(cnty11_4d, keep(treatment)  lpatt(solid) lcol(none) msym(o) msize(2) mcol(none ) ciopts(lpatt(solid) lcol(none))  mlabposition(1) mlabsize(4.2) mlabgap(*2) ) ///
	(cnty11_5d, keep(treatment)  lpatt(solid) lcol(black) msym(o) msize(2) mcol(black)  ciopts(lpatt(solid) lcol(black))  mlabposition(12)mlabsize(4.2) mlabgap(*2)  ) ///
	(cnty24_5d, keep(treatment)  lpatt(solid) lcol(red) msym(triangle) msize(2) mcol(red )  ciopts(lpatt(solid) lcol(red))  mlabposition(12)mlabsize(4.2) mlabgap(*2)  ) ///
	(all_5d, keep(treatment)  lpatt(solid) lcol(blue) msym(square) msize(2) mcol(blue )  ciopts(lpatt(solid) lcol(blue))  mlabposition(12)mlabsize(4.2) mlabgap(*2)  ) ///
	(cnty11_5d, keep(treatment)  lpatt(solid) lcol(none) msym(o) msize(2) mcol(none ) ciopts(lpatt(solid) lcol(none))  mlabposition(1) mlabsize(4.2) mlabgap(*2) ) ///
	(cnty11_5d, keep(treatment)  lpatt(solid) lcol(none) msym(o) msize(2) mcol(none ) ciopts(lpatt(solid) lcol(none))  mlabposition(1) mlabsize(4.2) mlabgap(*2) ) ///
	(cnty11_6d, keep(treatment)  lpatt(solid) lcol(black) msym(o) msize(2) mcol(black)  ciopts(lpatt(solid) lcol(black))  mlabposition(12)mlabsize(4.2) mlabgap(*2)  ) ///
	(cnty24_6d, keep(treatment)  lpatt(solid) lcol(red) msym(triangle) msize(2) mcol(red )  ciopts(lpatt(solid) lcol(red))  mlabposition(12)mlabsize(4.2) mlabgap(*2)  ) ///
	(all_6d, keep(treatment)  lpatt(solid) lcol(blue) msym(square) msize(2) mcol(blue )  ciopts(lpatt(solid) lcol(blue))  mlabposition(12)mlabsize(4.2) mlabgap(*2)  ), ///	
scheme(s1mono)  plotregion(lcolor(none))  ///
	horizontal xline(0,lwidth(thin) lpattern(dash)) ///
	grid(none) ///
	legend(size(medium) order(2 "尼日利亚" 4 "马里" 6 "全部" ) rows(1) region(lcolor(none))) ///
	title("", size(medium)) ///
	ylabel("", notick labsize(medium)) ///
	ytitle(	"6天       5天       4天      3天       2天      1天", size(medium)) 
graph export Tex/days.png,replace
 
 
*********************** robunest check
 
** interaction
meologit wom_empower treatment##president_coethnic urban female poverty ownership age education_dummy ///
radio_news ethnic_major president_coethnic if COUNTRY == 24 || REGION: 
* nothing here

meologit wom_empower treatment##radio_news urban female poverty ownership age education_dummy ///
radio_news ethnic_major president_coethnic if COUNTRY == 24 || REGION: 
 
 
ologit wom_empower treatment##c.radio_news urban female poverty ownership age education_dummy ///
radio_news ethnic_major president_coethnic if COUNTRY == 24 
 
 
*504  = Ségou, REGION
* Bauchi = 624   REGION
* 655 = Yobe;

 
ologit wom_empower treatment urban female poverty ownership age education_dummy ///
radio_news ethnic_major president_coethnic if REGION == 504

ologit wom_empower treatment urban female poverty ownership age education_dummy ///
radio_news ethnic_major if REGION == 624
* attacks after survey one


*choose neighbiring

ologit wom_empower treatment urban female poverty ownership age education_dummy ///
radio_news ethnic_major if REGION == 655
** all conducted after attacks
ologit wom_empower treatment urban female poverty ownership age education_dummy ///
radio_news ethnic_major if REGION == 655 | REGION == 624

 
 
meologit manage_econ treatment urban female poverty ownership age education_dummy ///
radio_news ethnic_major president_coethnic if COUNTRY == 24 || REGION: 

meologit Y_Q22 treatment urban female poverty ownership age education_dummy ///
radio_news ethnic_major president_coethnic if COUNTRY == 24 || REGION: 

meologit Y_Q23 treatment urban female poverty ownership age education_dummy ///
radio_news ethnic_major president_coethnic if COUNTRY == 24 || REGION: 

estimates store nigeria

* model 2
meologit manage_econ treatment urban female poverty ownership age education_dummy ///
radio_news ethnic_major president_coethnic if COUNTRY == 11 || REGION: 
 
 
 meologit impro_living treatment urban female poverty ownership age education_dummy ///
radio_news ethnic_major president_coethnic if COUNTRY == 24 || REGION: 
estimates store nigeria

* model 2
meologit impro_living treatment urban female poverty ownership age education_dummy ///
radio_news ethnic_major president_coethnic if COUNTRY == 11 || REGION: 
 
 
 
 
 
 
 
 
meologit Y_Q22 treatment urban female poverty ownership age education_dummy ///
radio_news ethnic_major president_coethnic || REGION: 

meologit Y_Q65P treatment urban female poverty ownership age education_dummy ///
radio_news ethnic_major president_coethnic || REGION: 


meologit Y_Q56D treatment urban female poverty ownership age education_dummy ///
radio_news ethnic_major president_coethnic || REGION: 


*meologit Y_Q56E treatment urban female poverty ownership age education_dummy ///
*radio_news ethnic_major president_coethnic || REGION: 

ologit Y_Q65P treatment urban female poverty ownership age education_dummy ///
radio_news ethnic_major president_coethnic i.REGION

ologit Y_Q65P treatment urban female poverty ownership age education_dummy ///
radio_news ethnic_major president_coethnic, vce(cluster REGION)

ologit Y_Q22 treatment urban female poverty ownership age education_dummy ///
radio_news ethnic_major president_coethnic 


*** ONly Mali: women empowerment
use "/Users/chongchen/Documents/Research/SurveyProject/Data/df_mali.dta", clear

meologit Y_Q57P treatment urban female poverty ownership age education_dummy ///
radio_news ethnic_major president_coethnic || REGION: 

ologit Y_Q57P treatment urban female poverty ownership age education_dummy ///
radio_news ethnic_major president_coethnic i.REGION if COUNTRY == 24





*** pooled sample


meologit wom_empower treatment urban female poverty ownership age education_dummy  ///
radio_news ethnic_major president_coethnic || COUNTRY: || REGION: 



*meologit Y_Q23 treatment urban female poverty ownership age education_dummy ///
*radio_news ethnic_major president_coethnic || REGION: 


*meologit Y_Q56C treatment urban female poverty ownership age education_dummy ///
*radio_news ethnic_major president_coethnic || REGION: 


/* #Question Number: Q22
#Question: Which of the following statements is closest to your view? Choose Statement 1 or Statement 2.
#Statement 1: Men make better political leaders than women, and should be elected rather than women.
#Statement 2: Women should have the same chance of being elected to political office as men.
#Value Labels: 1=Agree very strongly with Statement 1, 2=Agree with Statement 1, 
#3=Agree with Statement 2, 4=Agree very strongly with Statement 2, 5=Agree with neither,
#9=Don’t know, 998=Refused to answer, -1=Missing */

/* #Question Number: Q65P
table(afrov5_nigeria$Q65P)
#Question: How well or badly would you say the current government is handling the following matters, or haven’t you heard enough to say: Empowering women?
#1=Very badly, 2=Fairly badly, 3=Fairly well, 4=Very well, 9=Don’t know/Haven’t heard enough, 998=Refused to answer, -1=Missing
*/

/*
#Question Number: Q56D
table(afrov5_nigeria$Q56D)
#Question: In your opinion, how often, in this country: Are women treated unequally by the police and courts?
 # Variable Label: How often women treated unequally by police and courts
#0=Never, 1=Rarely, 2=Often, 3=Always, 9=Don’t know, 998=Refused to answer, -1=Missing
*/
